﻿#!/bin/bash
#
#Installation on Debian
#You can install openmediavault on a Debian installation as well.
#To do so, on x86 simply install the system using the Debian netinst images. After that apply the commands below. Please do not install a graphical environment, use a minimal server installation only. For a step by step install guide have a look into the Debian minimal install guide.
#On ARM devices check if there’s an appropriate Armbian Buster (Debian 10) image available. After installing Armbian then use the armbian-config tool to install OMV in a single step with all performance and reliability tweaks included. If there’s no Armbian for your device simply follow the steps outlined below.
#On Raspberry Pi OS the below instructions only partially work. Please refer to a specific installation script
#Install the openmediavault keyring manually:

apt-get install --yes gnupg
wget -O "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc" https://packages.openmediavault.org/public/archive.key
apt-key add "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc"
#Add the package repositories:

cat <<EOF >> /etc/apt/sources.list.d/openmediavault.list
deb https://packages.openmediavault.org/public usul main
# deb https://downloads.sourceforge.net/project/openmediavault/packages usul main
## Uncomment the following line to add software from the proposed repository.
# deb https://packages.openmediavault.org/public usul-proposed main
# deb https://downloads.sourceforge.net/project/openmediavault/packages usul-proposed main
## This software is not part of OpenMediaVault, but is offered by third-party
## developers as a service to OpenMediaVault users.
# deb https://packages.openmediavault.org/public usul partner
# deb https://downloads.sourceforge.net/project/openmediavault/packages usul partner
EOF
#Note
#If you are a user in mainland China, TUNA provides mirroring services.
#Install the openmediavault package:

export LANG=C.UTF-8
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
apt-get update
apt-get --yes --auto-remove --show-upgraded \
    --allow-downgrades --allow-change-held-packages \
    --no-install-recommends \
    --option DPkg::Options::="--force-confdef" \
    --option DPkg::Options::="--force-confold" \
    install openmediavault-keyring openmediavault

omv-confdbadm populate

#The user name is admin and default password is openmediavault

#OVM Extra	
#Update:
#So I've found a Solution but I'm not feeling well with downgrading so much packages, this meight lead to some other issues in the future if I'm not wrong.
#So first I had to add a repo which includes the missing packages and 
#I added "deb http://ftp.de.debian.org/debian buster main" to the /etc/apt/source.list .
#so I could fire the following commands downgrading and adding the missing packages and their dependencies.
#after that the install script
#Code
#wget -O - https://github.com/OpenMediaVault-Plugin-Developers/packages/raw/master/install | bash
#worked and now OVM Extra Tab is available.
